package com.suny.thread_specifics_storage;

public class Log {
    private static final ThreadLocal<TSLog> LOCAL = new ThreadLocal<>();

    public static void println(String s) {
        getLog().println(s);
    }

    public static void close() {
        getLog().close();
    }


    public static TSLog getLog() {
        TSLog log = LOCAL.get();

        if (log == null) {
            log = new TSLog(Thread.currentThread().getName() + "-log.txt");
            LOCAL.set(log);
        }
        return log;
    }
}
